import { _decorator, assetManager, AssetManager, AudioSource, Canvas, Component, error, instantiate, js, Node, Prefab, ResolutionPolicy, screen, Size, UITransform, view,} from 'cc';
import { ResManager } from '../GScript/core/modules/res/resManager';
import { UiManager } from '../GScript/core/modules/ui/UiManager';
const { ccclass, property } = _decorator;

/** 
 * 画布的标准化尺�?�，就是之前说的
 * iPad 设�?�中的画布尺�? = 1001 x 1334 (其中 1001 �? 1668/1.6672)
 * iPhone16设�?�中的画布尺�? = 750 x1626（其�? 1626 = 2556/1.572�?
 */
export const G_VIEW_SIZE = new Size(0, 0);

@ccclass('Boost')
export class Boost extends Component {

    @property(Canvas)
    private canvas2d:Canvas = null

    private loadBundle(bundleName:string):Promise<AssetManager.Bundle>{
        return new Promise<AssetManager.Bundle>(rs => {
            assetManager.loadBundle(bundleName,(e,asset) => {
                if(e){
                    console.error(e)
                    rs(null)
                    return
                }
                rs(asset)
            });
        })
    }


    async start() {
        await this.loadBundle("GScriptBN");
        const gCtr:any = this.node.addComponent("GCtr");
        await gCtr.init({
            canvas2d:this.canvas2d
        })


        // const WIN_SIZE_W  = screen.windowSize.width;
        // const WIN_SIZE_H = screen.windowSize.height;

        // let isScreenWidthLarger = this.adapterScreen();

        // if(isScreenWidthLarger){
        //     screen.windowSize = new Size(WIN_SIZE_W+1,WIN_SIZE_H)
        //     screen.windowSize = new Size(WIN_SIZE_W,WIN_SIZE_H)
        // }
        // this.adapterScreen()

        // ResManager.getInstance().loadBundle("LoginBN",_=>{
        //     const loginEntryClass = js.getClassByName("LoginEntry") as typeof Component;
        //     this.node.addComponent(loginEntryClass)
        // })

    }
    
}


